
import javax.swing.*;
public class Caractere extends Responsabil{
    private JFrame f;
    Caractere(JFrame f){
        this.f = f;
    }
    public boolean test(String s){
        boolean rez = true;
        char c;
        for(int i = 0; i < s.length(); i++)
        {
            c = s.charAt(i);
            if((c=='A')||(c=='B')||(c=='E')||(c=='F')||(c=='G')||(c=='H')||(c=='J')||(c=='K')||(c=='N')||(c=='O')
              ||(c=='P')||(c=='Q')||(c=='R')||(c=='S')||(c=='T')||(c=='U')||(c=='W')||(c=='Y')||(c=='Z')){
            	rez = false;
                break;
            }
        }
        if(rez == false)
            mesaj(f);
        else{
            if(this.next != null)
                next.test(s);
        }
        return rez;
    }
    public void mesaj(JFrame f){
       JOptionPane.showMessageDialog(f, "Ati introdus un cuvant care contine caractere invalide", "Eroare", JOptionPane.ERROR_MESSAGE);
       System.exit(1);
    }

}
